package localcreate;

import com.ndp.fb.util.FileUtil;

import java.io.File;
import java.util.List;

/**
 * Created by hunk.qin on 2015/4/22.
 */
public class Main  {

    public static void main(String[] args) throws  Exception{
        List<String> list= FileUtil.getFileConntent(new File("e:\\language.txt"),"UTF-8");
        StringBuffer stringBuffer=new StringBuffer("location:[");
        String currentlocal="";
        for (String s : list) {
            String [] array=s.split(",");
            if(!currentlocal.equals(array[0].trim())){
                stringBuffer.append("],");
                currentlocal=array[0].trim();
                stringBuffer.append("\""+currentlocal+"\":[{\n");
            }
                stringBuffer.append("{" + "name:\""+array[1].trim()+"\", code:\""+array[2].trim()+"\"" + "},\n");
        }

        System.out.println(stringBuffer.toString());

      /*  Map<String,Local> maplocal=new HashMap<>();
        for (String s : list) {
             String [] array=s.split(",");
             maplocal.put(array[0],new Local(array[1],array[2]));
        }
        System.out.println(JSON.toJSONString(maplocal));*/
    }
}
